import { _decorator, Component, Node } from 'cc';
import { App } from '../../../App';
import { EventConst } from '../../../common/Common';
import { PD } from '../../../player/PlayerData';
import { GameBaseModel } from '../GameBaseModel';
import { PlayBaseUser } from '../PlayBaseUser';
const { ccclass, property } = _decorator;

export class GameMulitUser extends PlayBaseUser {
    

    constructor(key, nickname, userData) {
        super()
        this.initData(key, nickname, userData)
    }

    initData(key, nickname, userData) {
        this.userAddress = key
        this.userNickname = nickname
        this.ballList = userData
        this.allBallList = userData
        this.isOwner = this.userAddress == App.Model.gameManage.houseOwnerAccount
        this.mine = key==PD.user.addressUrl
    }

    onCue() {
        let gameView = App.Model.gameView as GameBaseModel
        if (gameView.node==null) return
        
        gameView.cueCtrl.showCue(this.mine)
        // let cueAngle = 30
        // let force = 100
        // this.gameLogic.cue.cueMoveAction(cueAngle, force)

    }

    posWhiteBall() {
        App.Event.emit(EventConst.POS_WHITE_BALL, this.mine)
    }
    
    getName(): String {
        return PD.user.addressUrl
    }

}

